<template>
  <div class="detail-page">
    <Layout>
      <template #main>
        <div class="main-container" v-loading="isLoading">
          <BlogDetail :blog="data" v-if="data"></BlogDetail>
          <BlogComment v-if="!isLoading"></BlogComment>
        </div>
      </template>

      <template #right>
        <div class="toc">
          <BlogTOC :toc="data.toc"></BlogTOC>
        </div>
      </template>
    </Layout>
  </div>
</template>

<script>
import BlogComment from './components/BlogComment.vue';
import Layout from '@/components/Layout'
import BlogDetail from './components/BlogDetail.vue';
import BlogTOC from './components/BlogTOC.vue';
import fetchData from '@/mixins/fetchData';
import { getBlog } from '../../api/blog';
export default {
  components: {
    Layout,
    BlogDetail,
    BlogTOC,
    BlogComment
  },
  mixins: [fetchData({})],
  methods: {
    async fetchData() {
      return await getBlog(this.$route.params.id)
    }
  }
}
</script>

<style lang="less" scoped>
@import "~@/styles/var.less";
.toc {
  width: 16vw;
}
.main-container {
  overflow-y: scroll;
  height: 100vh;
  box-sizing: border-box;
  padding: 20px;
  position: relative;
  width: 100%;
  overflow-x: hidden;
  scroll-behavior: smooth;

  &::-webkit-scrollbar {
    width: 8px;
    height: 8px;
    transition: all 300ms;
  }

  &::-webkit-scrollbar-track {
    background: @cyber;
    border-radius: 5px;
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
  }

  &::-webkit-scrollbar-thumb {
    // background: linear-gradient(@, darken(@white, 1%));
    background: @white;
    border-radius: 5px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
  }

  &::-webkit-scrollbar-corner {
    background: #f1f1f1;
  }
}
</style>